package com.neusoft.neu24.nep.bootaop.demos.cfg;


import com.neusoft.neu24.nep.bootaop.demos.interceptor.MyInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 注册拦截器
 */
@Configuration
public class MyMvcConfig implements WebMvcConfigurer {

    @Autowired
    private MyInterceptor myInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry
//                拦截
                .addInterceptor(myInterceptor).addPathPatterns("/**")
//                排除
                .excludePathPatterns("/hello");
    }
}